<include file="Public/min-header"/>
<div class="wrapper">
    <include file="Public/breadcrumb"/>
    <style>#search-form > .form-group{margin-left: 10px;}</style>
    <!-- Main content -->
    <section class="content">
        <div class="container-fluid">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><i class="fa fa-list"></i> 奖品列表</h3>
                </div>
                <div class="panel-body">
                    <div class="navbar navbar-default">
                        <form style="display: inline-block" action="" id="search-form2" class="navbar-form form-inline" method="post" onsubmit="return false">
                            <!--<div class="form-group">-->
                            <!--<select name="is_on_sale" id="is_on_sale" class="form-control">-->
                            <!--<option value="">全部</option>-->
                            <!--<option value="1">上架</option>-->
                            <!--<option value="0">下架</option>-->
                            <!--</select>-->
                            <!--</div>-->

                            <div class="form-group">
                                <label class="control-label" for="input-order-id">关键词</label>
                                <div class="input-group">
                                    <input type="text" name="key_word" value="" placeholder="搜索词" id="input-order-id" class="form-control">
                                </div>
                            </div>
                            <div class="form-group">
                                <select name="grant" class="form-control">
                                    <option value="">请选择</option>
                                    <option value="1">已发放</option>
                                    <option value="0">未发放</option>
                                </select>
                            </div>
                            <button type="button" id="button-filter search-order" class="btn btn-primary search_prize" data-toggle='tooltip'data-original-title="筛选"><i class="fa fa-search"></i> 筛选</button>
                        </form>
                    </div>
                    <div id="ajax_return"></div>
                </div>
                <div class="box-body">
                    <div class="row">
                        <div class="col-sm-12">
                            <table id="list-table" class="table table-bordered table-striped dataTable">
                                <thead>
                                <tr role="row">
                                    <th>id</th>
                                    <th>奖品名称</th>
                                    <th>奖品类型</th>
                                    <th>获奖人</th>
                                    <th>中奖时间</th>
                                    <th>是否发奖</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <foreach name="lotteryRecordData" item="vo" key="k" >
                                    <tr role="row">
                                        <td>{$vo[id]}</td>
                                        <td>{$vo[prize_name]}</td>
                                        <td>{$vo[category_name]}</td>
                                        <td>{$vo[nickname]}</td>
                                        <td>{$vo[create_time]}</td>
                                        <td><if condition="$vo[grant] eq 1"> 已发放<else />未发放</if></td>
                                        <td>
                                            <if condition="$vo[grant] eq 0">
                                                    <button type="button" data-id="{$vo[id]}" data-status="1" class="btn btn-warning change_grant">发放</button>
                                                <else />
                                                    <button type="button" data-id="{$vo[id]}" data-status="0" class="btn btn-success change_grant">改为未发放</button>
                                            </if>
                                            <!--<a class="btn btn-primary" href="{:U('Lottery/addPrize',array('prize_id'=>$vo['prize_id']))}" data-toggle='tooltip'data-original-title="修改"><i class="fa fa-pencil"></i></a>-->
                                            <!--<a class="btn btn-danger prize_del" data-id="{$vo.prize_id}" data-toggle='tooltip'data-original-title="删除"><i class="fa fa-trash-o"></i></a>-->
                                        </td>
                                    </tr>
                                </foreach>
                                </tbody>
                                <tfoot>

                                </tfoot>
                            </table>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-6 text-left">
                            <button class="btn btn-default btn-sm checkbox-toggle"><i class="fa fa-square-o"></i></button>
                        </div>
                        <div class="col-sm-6 text-right">{$page}</div>
                    </div>
                </div>
            </div>
        </div>
        <!-- /.row -->
    </section>
    <!-- /.content -->
</div>
<!-- /.content-wrapper -->
<script>
    $(function () {
        $(document).on('click','.search_prize',function () {
            var keyWork = $("input[name='key_word']").val();
            var grant = $("select[name='grant']").val();
            location.href='/index.php?m=Admin&c=Lottery&a=recordList&key_word='+keyWork+'&grant='+grant;
        })
        $(document).on('click','.change_grant',function () {
            var id = $(this).data('id');
            var status = $(this).data('status');
            $.ajax({
                type:'post',
                data:{id:id,status:status},
                url:'/index.php?m=Admin&c=Lottery&a=changeGrant',
                dataType:'json',
                success:function(msg){
                    if(msg.result == 200 || msg.result == '200'){
                        history.go(0);
                    }else{
                        layer.msg(res.message, {icon: 2,time: 1000});
                    }
                }
            })
        })
    })

</script>
</body>
</html>